#include "wds_vars.h"
#include "build.h"
#include "wds_game.h"
#include "gen_game_state.h"
#include "wds_bullet_manager.h"

#include "application/game_rms.h"

#ifdef _PLATFORM_IOS
#include <sys/types.h>
#include <sys/sysctl.h>

#endif


WDSVars::WDSVars() : GameRMS()
{
	
}

void	WDSVars::ResetCustom()
{
    
#if defined(_PLATFORM_IOS) || defined( _PLATFORM_ANDROID)
    GameRMS::Instance()->SetCanTilt(true);
	//GameRMS::Instance()->SetCanVibrate(IsVibrationAvilable());
#endif
    
	if(!GetProfile())
	{
#ifdef _BUILD_CHINESE
		AddProfile("Neo","Chinese","ac");	
#else
		AddProfile("Neo","English","ac");	
#endif

	}
}



int		WDSVars::GetCurrentLevel()
{
	return	GetInt(VAR_NAMES_CURRENT_LEVEL);
}
	
int		WDSVars::GetMaxPlayableLevel()
{
	return	GetInt(VAR_NAMES_MAX_PLAYABLE_LEVEL);
}

void		WDSVars::SetCurrentLevel(int LevelNum)
{
	SetInt(VAR_NAMES_CURRENT_LEVEL,LevelNum);
}

void		WDSVars::SetMaxPlayableLevel(int LevelNum)
{
	SetInt(VAR_NAMES_MAX_PLAYABLE_LEVEL,LevelNum);
}

void		WDSVars::LoadCustom(util::FileIO* pFile)
{
	GameRMS::LoadCustom(pFile);
	SetData();
	
}

void		WDSVars::SaveCustom(util::FileIO* pFile)
{
	GameRMS::SaveCustom(pFile);
	SetData();
}


void		WDSVars::SetData()
{
	GENGameState* pGameState = GENGameState::GetGame();

	if(!pGameState)
		return;

	WDSGame* pGame = pGameState->GetGameWDS();
	if(!pGame)
		return;

	WDSPlayer* pPlayer = pGame->GetPlayer();
	if(!pPlayer)
		return;

	WDSPlayer::Skill* pPlayerSkill = pPlayer->GetSkill();
	

	int Temp = GetInt(VAR_NAMES_FASTLOADER);
	if( Temp == 0 )
		pPlayerSkill->m_FastLoader = 1.0f;	
	else if (  Temp == 1 )	
		pPlayerSkill->m_FastLoader = 1.1f;	
	else if (  Temp > 1 )	
		pPlayerSkill->m_FastLoader = 1.2f;
	

	Temp = GetInt(VAR_NAMES_FASTSHOT);
	if( Temp == 0 )	
		pPlayerSkill->m_FastShot = 1.0f;	
	else if (  Temp == 1 )	
		pPlayerSkill->m_FastShot = 1.1f;	
	else if (  Temp > 1 )	
		pPlayerSkill->m_FastShot = 1.2f;
	

	Temp = GetInt(VAR_NAMES_MOVESPEED);
	if( Temp == 0 )	
		pPlayerSkill->m_MoveSpeed = 1.0f;	
	else if (  Temp == 1 )	
		pPlayerSkill->m_MoveSpeed = 1.1f;	
	else if (  Temp > 1 )	
		pPlayerSkill->m_MoveSpeed = 1.2f;
	

	Temp = GetInt(VAR_NAMES_REFLEX);
	if( Temp == 0 )	
		pPlayerSkill->m_Reflex = 1.0f;	
	else if (  Temp == 1 )	
		pPlayerSkill->m_Reflex = 0.9f;	
	else if (  Temp > 1 )	
		pPlayerSkill->m_Reflex = 0.8f;
	

	Temp = GetInt(VAR_NAMESEXTRAAMMO);
	if( Temp == 0 )	
		pPlayerSkill->m_ExtraAmmo = 1.0f;	
	else if (  Temp == 1 )	
		pPlayerSkill->m_ExtraAmmo = 1.1f;	
	else if (  Temp > 1 )	
		pPlayerSkill->m_ExtraAmmo = 1.2f;
	

	Temp = GetInt(VAR_NAMES_BONUSMAGNET);
	if( Temp == 0 )	
		pPlayerSkill->m_BonusMagnet = 1.0f;	
	else if (  Temp == 1 )	
		pPlayerSkill->m_BonusMagnet = 1.1f;	
	else if (  Temp > 1 )	
		pPlayerSkill->m_BonusMagnet = 1.2f;

	Temp = GetInt(VAR_NAMES_REGENERATION);
	if( Temp == 0 )	
		pPlayerSkill->m_Regeneration = 1.0f;	
	else if (  Temp == 1 )	
		pPlayerSkill->m_Regeneration = 1.1f;	
	else if (  Temp > 1 )	
		pPlayerSkill->m_Regeneration = 1.2f;	
		
	
	WDSBulletManager::Skill* pBulletSkill = WDSBulletManager::Instance().GetSkill();	

	Temp = GetInt(VAR_NAMES_SILVERBULLET);
	if( Temp == 0 )	
		pBulletSkill->m_SilverBullet = 1.0f;	
	else if (  Temp == 1 )	
		pBulletSkill->m_SilverBullet = 1.1f;	
	else if (  Temp > 1 )	
		pBulletSkill->m_SilverBullet = 1.2f;

	Temp = GetInt(VAR_NAMES_BULLETSPEED);
	if( Temp == 0 )	
		pBulletSkill->m_BulletSpeed = 1.0f;	
	else if (  Temp == 1 )	
		pBulletSkill->m_BulletSpeed = 1.1f;	
	else if (  Temp > 1 )	
		pBulletSkill->m_BulletSpeed = 1.2f;
	

	Temp = GetInt(VAR_NAMES_IONGUNMASTER);
	if( Temp == 0 )	
		pBulletSkill->m_IONGunMaster = 1.0f;	
	else if (  Temp == 1 )	
		pBulletSkill->m_IONGunMaster = 1.1f;	
	else if (  Temp > 1 )	
		pBulletSkill->m_IONGunMaster = 1.2f;

		
		
		
}


